package sqlTestes.criarSqlDeUmaTabela;

import infra.Cenario;
import junit.framework.Assert;

import org.junit.Test;

import sql.ddl.Tabela;

public class TabelaComPrimaryKeyDefault extends Cenario {
	Tabela tabela = null;

	String sql;

	public void dadoQue() {
		aTabelaTemNomeAguaComPrimaryKeyDefault();
	}

	public void quando() {
		criarOSql();
	}

	public void entao() {
		oSqlSeraCreateTable__PK___();
		try {
			aTabelaTeraAPrimaryKeyDefault();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void aTabelaTemNomeAguaComPrimaryKeyDefault() {
		tabela = new Tabela("Tabela", true);
	}

	public void criarOSql() {
		sql = tabela.codigoSQL();
	}

	@Test
	public void oSqlSeraCreateTable__PK___() {
		Assert.assertEquals("CREATE TABLE Tabela(pkTabela SERIAL NOT NULL,"
				+ "CONSTRAINT TABELA_CHAVE PRIMARY KEY(pkTabela))", sql);
	}

	@Test
	public void aTabelaTeraAPrimaryKeyDefault() throws Exception {

			Assert.assertNotNull(tabela.getPrimaryKey());
	}

	@Test
	public void aTabelaTemUmaColuna() {
		Assert.assertEquals(1, tabela.getALLColunas().size());

	}

}